home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / lat1bang.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  9KB  |  302 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    latin1_bangbang
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. static const char *translation_table[256] =
  25.   {
  26.     "!!@",            /* \000 */
  27.     "!!a",            /* \001 */
  28.     "!!b",            /* \002 */
  29.     "!!c",            /* \003 */
  30.     "!!d",            /* \004 */
  31.     "!!e",            /* \005 */
  32.     "!!f",            /* \006 */
  33.     "!!g",            /* \007 */
  34.     "!!h",            /* \010 */
  35.     "!!i",            /* \011 */
  36.     "!!j",            /* \012 */
  37.     "!!k",            /* \013 */
  38.     "!!l",            /* \014 */
  39.     "!!m",            /* \015 */
  40.     "!!n",            /* \016 */
  41.     "!!o",            /* \017 */
  42.     "!!p",            /* \020 */
  43.     "!!q",            /* \021 */
  44.     "!!r",            /* \022 */
  45.     "!!s",            /* \023 */
  46.     "!!t",            /* \024 */
  47.     "!!u",            /* \025 */
  48.     "!!v",            /* \026 */
  49.     "!!w",            /* \027 */
  50.     "!!x",            /* \030 */
  51.     "!!y",            /* \031 */
  52.     "!!z",            /* \032 */
  53.     "!![",            /* \033 */
  54.     "!!\\",            /* \034 */
  55.     "!!]",            /* \035 */
  56.     "!!^",            /* \036 */
  57.     "!!_",            /* \037 */
  58.     " ",            /* \040 */
  59.     "!\"",            /* \041 */
  60.     "\"",            /* \042 */
  61.     "#",            /* \043 */
  62.     "$",            /* \044 */
  63.     "%",            /* \045 */
  64.     "&",            /* \046 */
  65.     "'",            /* \047 */
  66.     "(",            /* \050 */
  67.     ")",            /* \051 */
  68.     "*",            /* \052 */
  69.     "+",            /* \053 */
  70.     ",",            /* \054 */
  71.     "-",            /* \055 */
  72.     ".",            /* \056 */
  73.     "/",            /* \057 */
  74.     "0",            /* \060 */
  75.     "1",            /* \061 */
  76.     "2",            /* \062 */
  77.     "3",            /* \063 */
  78.     "4",            /* \064 */
  79.     "5",            /* \065 */
  80.     "6",            /* \066 */
  81.     "7",            /* \067 */
  82.     "8",            /* \070 */
  83.     "9",            /* \071 */
  84.     ":",            /* \072 */
  85.     ";",            /* \073 */
  86.     "<",            /* \074 */
  87.     "=",            /* \075 */
  88.     ">",            /* \076 */
  89.     "?",            /* \077 */
  90.     "@",            /* \100 */
  91.     "!a",            /* \101 */
  92.     "!b",            /* \102 */
  93.     "!c",            /* \103 */
  94.     "!d",            /* \104 */
  95.     "!e",            /* \105 */
  96.     "!f",            /* \106 */
  97.     "!g",            /* \107 */
  98.     "!h",            /* \110 */
  99.     "!i",            /* \111 */
  100.     "!j",            /* \112 */
  101.     "!k",            /* \113 */
  102.     "!l",            /* \114 */
  103.     "!m",            /* \115 */
  104.     "!n",            /* \116 */
  105.     "!o",            /* \117 */
  106.     "!p",            /* \120 */
  107.     "!q",            /* \121 */
  108.     "!r",            /* \122 */
  109.     "!s",            /* \123 */
  110.     "!t",            /* \124 */
  111.     "!u",            /* \125 */
  112.     "!v",            /* \126 */
  113.     "!w",            /* \127 */
  114.     "!x",            /* \130 */
  115.     "!y",            /* \131 */
  116.     "!z",            /* \132 */
  117.     "[",            /* \133 */
  118.     "\\",            /* \134 */
  119.     "]",            /* \135 */
  120.     "^",            /* \136 */
  121.     "_",            /* \137 */
  122.     "!@",            /* \140 */
  123.     "a",            /* \141 */
  124.     "b",            /* \142 */
  125.     "c",            /* \143 */
  126.     "d",            /* \144 */
  127.     "e",            /* \145 */
  128.     "f",            /* \146 */
  129.     "g",            /* \147 */
  130.     "h",            /* \150 */
  131.     "i",            /* \151 */
  132.     "j",            /* \152 */
  133.     "k",            /* \153 */
  134.     "l",            /* \154 */
  135.     "m",            /* \155 */
  136.     "n",            /* \156 */
  137.     "o",            /* \157 */
  138.     "p",            /* \160 */
  139.     "q",            /* \161 */
  140.     "r",            /* \162 */
  141.     "s",            /* \163 */
  142.     "t",            /* \164 */
  143.     "u",            /* \165 */
  144.     "v",            /* \166 */
  145.     "w",            /* \167 */
  146.     "x",            /* \170 */
  147.     "y",            /* \171 */
  148.     "z",            /* \172 */
  149.     "![",            /* \173 */
  150.     "!\\",            /* \174 */
  151.     "!]",            /* \175 */
  152.     "!^",            /* \176 */
  153.     "!_",            /* \177 */
  154.  
  155.     NULL,            /* \200 */
  156.     NULL,            /* \201 */
  157.     NULL,            /* \202 */
  158.     NULL,            /* \203 */
  159.     NULL,            /* \204 */
  160.     NULL,            /* \205 */
  161.     NULL,            /* \206 */
  162.     NULL,            /* \207 */
  163.     NULL,            /* \210 */
  164.     NULL,            /* \211 */
  165.     NULL,            /* \212 */
  166.     NULL,            /* \213 */
  167.     NULL,            /* \214 */
  168.     NULL,            /* \215 */
  169.     NULL,            /* \216 */
  170.     NULL,            /* \217 */
  171.     NULL,            /* \220 */
  172.     NULL,            /* \221 */
  173.     NULL,            /* \222 */
  174.     NULL,            /* \223 */
  175.     NULL,            /* \224 */
  176.     NULL,            /* \225 */
  177.     NULL,            /* \226 */
  178.     NULL,            /* \227 */
  179.     NULL,            /* \230 */
  180.     NULL,            /* \231 */
  181.     NULL,            /* \232 */
  182.     NULL,            /* \233 */
  183.     NULL,            /* \234 */
  184.     NULL,            /* \235 */
  185.     NULL,            /* \236 */
  186.     NULL,            /* \237 */
  187.  
  188.     " ",            /* \240 no-break space */
  189.     NULL,            /* \241 inverted exclamation mark */
  190.     NULL,            /* \242 cent sign */
  191.     NULL,            /* \243 pound sign */
  192.     NULL,            /* \244 currency sign */
  193.     NULL,            /* \245 yen sign */
  194.     NULL,            /* \246 broken bar */
  195.     NULL,            /* \247 paragraph sign, section sign */
  196.     NULL,            /* \250 diaeresis */
  197.     NULL,            /* \251 copyright sign */
  198.     NULL,            /* \252 feminine ordinal indicator */
  199.     "!>",            /* \253 left angle quotation mark */
  200.     NULL,            /* \254 not sign */
  201.     NULL,            /* \255 soft hyphen */
  202.     NULL,            /* \256 registered trade mark sign */
  203.     NULL,            /* \257 macron */
  204.     NULL,            /* \260 degree sign */
  205.     NULL,            /* \261 plus-minus sign */
  206.     NULL,            /* \262 superscript two */
  207.     NULL,            /* \263 superscript three */
  208.     NULL,            /* \264 acute accent */
  209.     NULL,            /* \265 small greek mu, micro sign */
  210.     NULL,            /* \266 pilcrow sign */
  211.     NULL,            /* \267 middle dot */
  212.     NULL,            /* \270 cedilla */
  213.     NULL,            /* \271 superscript one */
  214.     NULL,            /* \272 masculine ordinal indicator */
  215.     "!?",            /* \273 right angle quotation mark */
  216.     NULL,            /* \274 vulgar fraction one quarter */
  217.     NULL,            /* \275 vulgar fraction one half */
  218.     NULL,            /* \276 vulgar fraction three quarters */
  219.     NULL,            /* \277 inverted question mark */
  220.     NULL,            /* \300 capital A with grave accent */
  221.     NULL,            /* \301 capital A with acute accent */
  222.     NULL,            /* \302 capital A with circumflex accent */
  223.     NULL,            /* \303 capital A with tilde */
  224.     NULL,            /* \304 capital A diaeresis */
  225.     NULL,            /* \305 capital A with ring above */
  226.     NULL,            /* \306 capital diphthong A with E */
  227.     NULL,            /* \307 capital C with cedilla */
  228.     NULL,            /* \310 capital E with grave accent */
  229.     NULL,            /* \311 capital E with acute accent */
  230.     NULL,            /* \312 capital E with circumflex accent */
  231.     NULL,            /* \313 capital E with diaeresis */
  232.     NULL,            /* \314 capital I with grave accent */
  233.     NULL,            /* \315 capital I with acute accent */
  234.     NULL,            /* \316 capital I with circumflex accent */
  235.     NULL,            /* \317 capital I with diaeresis */
  236.     NULL,            /* \320 capital icelandic ETH */
  237.     NULL,            /* \321 capital N with tilde */
  238.     NULL,            /* \322 capital O with grave accent */
  239.     NULL,            /* \323 capital O with acute accent */
  240.     NULL,            /* \324 capital O with circumflex accent */
  241.     NULL,            /* \325 capital O with tilde */
  242.     NULL,            /* \326 capital O with diaeresis */
  243.     NULL,            /* \327 multiplication sign */
  244.     NULL,            /* \330 capital O with oblique stroke */
  245.     NULL,            /* \331 capital U with grave accent */
  246.     NULL,            /* \332 capital U with acute accent */
  247.     NULL,            /* \333 capital U with circumflex accent */
  248.     NULL,            /* \334 capital U with diaeresis */
  249.     NULL,            /* \335 capital Y with acute accent */
  250.     NULL,            /* \336 capital icelandic THORN */
  251.     NULL,            /* \337 small german sharp s */
  252.     "!0",            /* \340 small a with grave accent */
  253.     NULL,            /* \341 small a with acute accent */
  254.     "!1",            /* \342 small a with circumflex accent */
  255.     NULL,            /* \343 small a with tilde */
  256.     NULL,            /* \344 small a with diaeresis */
  257.     NULL,            /* \345 small a with ring above */
  258.     NULL,            /* \346 small diphthong a with e */
  259.     "!=",            /* \347 small c with cedilla */
  260.     "!3",            /* \350 small e with grave accent */
  261.     "!2",            /* \351 small e with acute accent */
  262.     "!5",            /* \352 small e with circumflex accent */
  263.     "!4",            /* \353 small e with diaeresis */
  264.     NULL,            /* \354 small i with grave accent */
  265.     NULL,            /* \355 small i with acute accent */
  266.     "!7",            /* \356 small i with circumflex accent */
  267.     "!6",            /* \357 small i with diaeresis */
  268.     NULL,            /* \360 small icelandic eth */
  269.     NULL,            /* \361 small n with tilde */
  270.     NULL,            /* \362 small o with grave accent */
  271.     NULL,            /* \363 small o with acute accent */
  272.     "!8",            /* \364 small o with circumflex accent */
  273.     NULL,            /* \365 small o with tilde */
  274.     NULL,            /* \366 small o with diaeresis */
  275.     NULL,            /* \367 division sign */
  276.     NULL,            /* \370 small o with oblique stroke */
  277.     "!9",            /* \371 small u with grave accent */
  278.     NULL,            /* \372 small u with acute accent */
  279.     "!:",            /* \373 small u with circumflex accent */
  280.     NULL,            /* \374 small u with diaeresis */
  281.     NULL,            /* \375 small y with acute accent */
  282.     NULL,            /* \376 small icelandic thorn */
  283.     NULL,            /* \377 small y with diaeresis */
  284.   };
  285.  
  286. void
  287. STEP (FILE *input_file, FILE *output_file)
  288. {
  289.   int input_char;        /* current character */
  290.   const char *output_string;    /* translated characters */
  291.  
  292.   while (input_char = getc (input_file), input_char != EOF)
  293.     if (input_char == '\n')
  294.       putc ('\n', output_file);
  295.     else if (output_string = translation_table[input_char], output_string)
  296.       while (*output_string)
  297.     {
  298.       putc (*output_string, output_file);
  299.       output_string++;
  300.     }
  301. }
  302.